package unit5.part10;

import java.util.Objects;

public class EqualsTest {
    public static void main(String[] args) {
        Plane planeA = new Plane("枭龙");
        Plane planeB = new Plane("威龙");
        Plane planeC = new Plane("威龙");
        System.out.println(planeB.equals(planeA));
        System.out.println(planeB.equals(planeC));
    }
}

class Plane {
    String name;

    public Plane(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Plane plane = (Plane) o;
        return Objects.equals(name, plane.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
